// UhfReadApi.h: interface for the UhfReadApi class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_UHFREADAPI_H__978A6203_4A49_41CA_A491_6B727C1C9AE2__INCLUDED_)
#define AFX_UHFREADAPI_H__978A6203_4A49_41CA_A491_6B727C1C9AE2__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "ComPort.h"

#define CMD_SET_BAUD 1
#define CMD_SET_TIME 0xF7
#define CMD_SET_ADDR 0xF8
#define CMD_SET_WG   0xF9
#define CMD_SET_WORKMODE 0xFB
#define CMD_GET_CONFIG 0xFA
#define CMD_SET_LED  0xFF
#define CMD_SET_BUZZ 0xff
#define CMD_SET_FACTORY 0x0D
#define CMD_SELECT_AERIAL 0x0A	//选天线
#define CMD_BEGIN_LIST_LABEL 0xEE
#define CMD_GET_BASIC_PARAM 0x06
#define CMD_SET_BASIC_PARAM 0x09	//写基本参数
#define CMD_GETFREQ 0x87	//读取频率


#include "common.h"

typedef int (*p_ReadLabelCallback)(void *pSender, BYTE *bData, int nLen);

class UhfReadApi  
{
public:
	UhfReadApi();
	virtual ~UhfReadApi();

public:
	int UhfGetConfig(unsigned char *config);
	int UhfSetWorkMode(unsigned char mode);
	int UhfGetFrequencyRange(BYTE *Frequency);
	int UhfWriteBasicParam(ReaderBasicParam * pParam);
	int UhfReadBasicParam(ReaderBasicParam * pParam);
	int UhfSetAntenna(int Antenna);
	int UhfStopAutoReadEPC();
	int UhfReadTag(BYTE *data, int dwLen);
	int UhfAutoReadLabelID(BYTE mem, int ptr, BYTE len, BYTE *mask , unsigned char *IDBuffer, int *nCounter, p_ReadLabelCallback ReadLabelCallback, void *Parent);
	int UhfReadFactoryParameter(int Address);
	int ReadData(BYTE *bData, int nLen);
	int UhfSendData(BYTE *bData, int iLen);
	int Rs232_ClosePort();
	int Rs232_OpenPort(int port, int baud);
	int UhfSetBuzzer(unsigned char baud);
	int UhfSetBuzzerLed(unsigned char baud);
	int UhfSetWg(unsigned char baud);
	int UhfSetAddress(unsigned char baud);
	int UhfSetTime(unsigned char baud);
	int UhfSetBaudrate(unsigned char baud);
	LsComm::CComPort m_serial;

	static p_ReadLabelCallback m_AutoReadLabel;

	HANDLE m_hComEvent;
	BYTE m_bData[256];
	int m_iLen;
};

extern UhfReadApi guhfapi;

#endif // !defined(AFX_UHFREADAPI_H__978A6203_4A49_41CA_A491_6B727C1C9AE2__INCLUDED_)
